package com.cysnake.easyyi.tools;

import android.util.Log;
import android.widget.ImageView;

import com.cysnake.easyyi.R;

public class CommonTool {
	public static int getYinYang(double seed) {
		int x = 50 - 1;
		for (int i = 0; i < 3; i++) {
			int x1 = (int) Math.round((x - 1) * seed);
			int x2 = x - x1;
			x1 = x1 % 4;
			if (x1 == 0) {
				x1 = 4;
			}
			x2 = (x2 - 1) % 4;
			if (x2 == 0) {
				x2 = 4;
			}
			x = x - x1 - x2 - 1;
		}
		return x / 4;
	}

	public static String getYinYangName(int num) {
		switch (num) {
		case 6:
			return "老阴";
		case 7:
			return "少阳";
		case 8:
			return "少阴";
		case 9:
			return "老阳";
		default:
			return null;
		}
	}

	public static void setImg(String name, ImageView view) {
		Log.i("test", "name =  " + name);
		if (name.equals("乾"))
			view.setImageResource(R.drawable.qian);
		if (name.equals("坤"))
			view.setImageResource(R.drawable.kun);
		if (name.equals("艮"))
			view.setImageResource(R.drawable.gen);
		if (name.equals("离"))
			view.setImageResource(R.drawable.li);
		if (name.equals("兑"))
			view.setImageResource(R.drawable.dui);
		if (name.equals("巽"))
			view.setImageResource(R.drawable.xun);
		if (name.equals("坎"))
			view.setImageResource(R.drawable.kan);
		if (name.equals("震"))
			view.setImageResource(R.drawable.zhen);

	}
	
	
}
